<template>
    <div>
        <yw-header></yw-header>
        <div class="search-view-layout">
            <div class="main-b">
                <div class="search-view-title">
                    <h2>搜索结果如下</h2>
                    <p>找到”{{name}}”相关陪玩师共{{searchList.length > 0 ? searchList.length : 0}}个</p>
                </div>
            </div>
        </div>
        <div class="main">
            <div class="accompanyPlay-anchor">
                <a v-for="(item,index) in searchList" :key="index" @click="detailLink(item)">
                    <img :src="$imgPath(item.headImg)">
                    <p>{{item.nickName}} </p>
                    <div class="accompanyPlay-anchor-msg accompanyPlay-anchor-status" style="border:none">
                        <i class="nan" v-if="item.sex == 1">{{item.age}}</i>
                        <i class="she" v-if="item.sex == 2">{{item.age}}</i>
                        <span class="adr">{{item.city | cityFilter}}</span>
                        <!-- <span class="grade">{{item.attributeIds}}</span> -->
                        <label class="price">￥<span>{{item.price}}/</span>小时</label>
                    </div>
                    <!-- <div class="accompanyPlay-anchor-status">
                        <label class="ok">在线</label>
                        <label class="price">￥<span>{{item.price}}/</span>小时</label>
                    </div> -->
                </a>
                
            </div>
        </div>
        <yw-footer></yw-footer>
    </div>
</template>
<script>
import apiHttp from '../api/index.js'
import header from './common/header'
import footer from './common/footer'
export default {
    data(){
        return{
            name:this.$route.query.name,
            searchList:[]
        }
    },
    components:{
        'yw-header':header,
        'yw-footer':footer,
    },
    created(){
        this.getUserServiceAuth()
    },
    methods:{
        // 搜索
        getUserServiceAuth(){
            apiHttp.apiIndex.getUserServiceAuth(this.name,'',resp=>{
                if(resp.code == 200){
                    this.searchList = resp.data
                }
            })
        },
        // 跳转到详情页
        detailLink(item){
            this.$router.push({
                name:'detail',
                params:{
                    userId:item.id,
                },
                query:{
                    serviceId:item.serverId
                }
            })
        }
    },
    filters:{
        cityFilter(val){
            if(val && val.indexOf("/") != -1){
                return val.substring(val.indexOf("/") + 1,val.length)
            }else{
                return val
            }
        }
    }
}
</script>
<style scoped>
.main{
    overflow: hidden;
}
.accompanyPlay-anchor a p{
    padding: 10px;
}
</style>

